﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using _01_Tower4._0.CharacterBase;
using _01_Tower4._0.GameFrame;
using _01_Tower4._0.GameFrame.Manager;
using _01_Tower4._0.GameFrame.System;
using _01_Tower4._0.Interface;
using _01_Tower4._0.Tool;
using static _01_Tower4._0.GameFrame.Game;

namespace _01_Tower4._0.Scene
{
    internal class SceneMenu : IScene
    {
        public string Name => "SceneMenu";

        MenuSystem menu;
        Map map;
        IScene scene;
        

        public SceneMenu(IScene scene)
        {
            this.scene = scene;

            List<MenuSystem.MenuData> menuData = new();

            menuData.Add(new("开始游戏", () => { SceneManager.instance.Init(); SceneManager.instance.ChangeSceneByName("SceneMap1"); }));
            menuData.Add(new("继续游戏", () => SceneManager.instance.ChangeSceneByName("SceneMap1")));
            menuData.Add(new("设置", () => Utility.MyPrint("3", 2, 12)));
            menuData.Add(new("退出", () => Environment.Exit(0)));

            menu = new MenuSystem(menuData, 43, 15);

            EventSystem.Instance.AddEvent("更改选项名称", () => { menu.ChangeSelectionName(0, "重新开始"); });
            EventSystem.Instance.AddEvent("玩家死亡", () => { menu.ChangeSelectionName(0, "重新开始"); map.ChangePicture(1); });

            string[] paths = { "../../../Map/Title.csv", "../../../Map/Over.csv" };
            map = new Map(paths, 100, 15, 0, 0, this);
        }

        public void Init()
        {
            map.ChangePicture(0);
        }

        public void Input()
        {
            menu.Input();
        }


        public void Update()
        {

        }

        public void FixUpdate()
        {

        }

        public void Render()
        {
            menu.Render();
            map.Render();
        }
        public void End()
        {

        }
    }
}
